/**
 * Created by fifths on 17-9-13.
 */

import {FormControl} from '@angular/forms';

export function validateMoney(c: FormControl) {
  const MONEY_REGEXP = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;

  return MONEY_REGEXP.test(c.value) ? null : {
    validateMoney: {valid: false}
  };
}
